package com.amigo.online.consumer.video.controller;



import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.amigo.online.common.base.controller.BaseConsumerController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.common.param.dto.video.MusicDto;
import com.amigo.online.consumer.video.service.MusicService;

/**
 * 音乐相关
 * @author amigo
 *
 */
@RestController
@RequestMapping(value = "/music", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class MusicController extends BaseConsumerController {
	
	@Autowired
	MusicService musicService;

	//获得系统音乐列表
	@GetMapping(value = "/system/musics/{musicid}/{page}/{size}")
	public ResponseEntity<Response> myVideos(
			@PathVariable Long musicid,
			@PathVariable Integer page, 
			@PathVariable Integer size
			) {
		return musicService.myVideos(musicid,page,size);
	}
	
	//收藏音乐
	@GetMapping(value = "/collect/music/{musicid}")
	public ResponseEntity<Response> collectMusic(@PathVariable Long musicid) {
		return musicService.collectMusic(musicid);
	}
	
	
	//取消收藏音乐
	@DeleteMapping(value = "/cancel/collect/{musicid}")
	public ResponseEntity<Response> cancelCollect(@PathVariable Long musicid) {
		return musicService.cancelCollect(musicid);
	}
	
	//获取我收藏的音乐列表
	@GetMapping(value = "/my/collect/musics/{page}/{size}")
	public ResponseEntity<Response> myUpedVideos(@PathVariable Integer page, @PathVariable Integer size) {
		return musicService.myUpedVideos(page,size);
	}
	
	
	
	//获得全部数据
	@GetMapping(value="/getAll")
	public ResponseEntity<Response> getAll(){
		return musicService.getAll();
	}
	
	//新增音乐
	@PostMapping(value = "/new")
	public ResponseEntity<Response> newUserVideo(HttpServletRequest request) {
		MusicDto dto = (MusicDto) getDto(request,MusicDto.class);
		return musicService.newUserVideo(dto);
	}
	
}
